package org.fosis.ic;

import com.example.S.R;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

public class ActCounter extends Activity implements View.OnClickListener {
    private int currentNum = -1;
    /** Called when the activity is first created. */

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


        TextView countDisplay = (TextView) findViewById(R.id.countDisplay);
        updateCounter(countDisplay);
        countDisplay.setOnClickListener(this);
    }


    public void onClick(View view) {
        switch (view.getId()){
            case R.id.countDisplay:
                //TODO: Actual counting here!
                Log.d("CLICKED: ","Click Succseful!");
                updateCounter((TextView) view);
                break;
        }
    }

    public void updateCounter(TextView t){
    	//TODO when finished, ask to press different button, so not to miss completion message
        currentNum++;
        if(currentNum<33){
            t.setText("SubhanAllah " + currentNum+" out of 33");
        } else if(currentNum<66){
            t.setText("33 SubhanAllah Complete! \n AlhamduLilaah "+(currentNum-33)+" out of 33");
        } else if(currentNum<99){
            t.setText("33 SubhanAllah Complete! \n 33 Alhamdulilaah Complete! \n Allahu Akbar "+(currentNum-66)+" out of 33");
        } else{
            t.setText("33 SubhanAllah Complete! \n 33 Alhamdulilaah Complete! \n 33 Allahu Akbar Complete! \n" +
                    "You have completed your Tasbih. Tap to reset.");
            currentNum = -1;
        }

    }
}
